<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script src="../../static/admin/layui/layui.js"></script>
    <link rel="stylesheet" href="../../static/admin/layui/css/layui.css">
    <link rel="stylesheet" href="../../static/admin/css/login.css">
</head>
<body>
<script>

</script>
<form class="layui-form" action="">
    <div class="container">
        <div class="layui-form-mid layui-word-aux">
            <h2 id="login">小艾数据展示平台</h2>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="username" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密 &nbsp;&nbsp;码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">登录</button>
            </div>
        </div>
    </div>

    <div style="width:300px;margin:auto;left: 0;right: 0; padding:20px 0;position: fixed;bottom: 0px;justify-content: center;flex-direction: column; ">
        <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=42018502004474" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;">
            <img src="../../static/admin/images/beian.png" style="float:left;"/>
            <p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;">鄂公网安备 42018502004474号</p>
        </a>
    </div>
</form>

<script src="../../static/admin/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function(){
        var form = layui.form;
        var $ = layui.jquery;

        // 顶层判断
        $(document).ready(function () {
            if (window != top) {
                top.location.href = location.href;
            }
        });

        //监听提交
        form.on('submit(demo1)', function(data){
            $.ajax({
                url: '/web/login',
                data: JSON.stringify(data.field),
                contentType: 'application/json;charset=UTF-8',
                type: 'post',
                dataType : "json",
                success:function (data) {
                    console.log(data);
                    if(data){
                        localStorage.setItem("identity",data.type)
                        window.location.href = "/";
                        //
                        // console.log(data);
                        // console.log(localStorage.getItem("identity"));
                    }
                    else
                        alert("用户名或者密码不对");
                }
            });
            return false;
        });
    });
</script>

</body>
</html>